#include<iostream>
#include<vector>
using namespace std;

const int N = 15;
int n;
bool row[N],st1[N*2],st2[N*2];
int ret;

void dfs(int x){
	if(x > n){
		ret++;
		return;
	}
	for(int y = 1; y <= n; y++){
		if(row[y] || st1[y - x + n] || st2[x + y]) continue;
		row[y] = st1[y - x + n] = st2[x + y] = true;
		dfs(x + 1);
		row[y] = st1[y - x + n] = st2[x + y] = false;
	}
}

int main(){
	cin >> n;
	dfs(1);
	cout << ret << endl;
	return 0;
}
